package com.minhua.jijiehao2.mainframe.common.imageactivity.impl

import android.content.Context
import android.content.Intent
import android.text.TextUtils
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.minhua.jijiehao2.R
import com.minhua.jijiehao2.base.BaseActivity
import com.minhua.jijiehao2.mainframe.common.imageactivity.imp.IImageView
import kotlinx.android.synthetic.main.activity_image.*

class ImageActivity : BaseActivity<IImageView, ImagePresenter>(), IImageView {

    override fun getLayoutId(): Int = R.layout.activity_image

    override fun getPresenter(): ImagePresenter = ImagePresenter()


    companion object {
        fun intentStart(context: Context, url: String) {
            val intent = Intent(context, ImageActivity::class.java)
            intent.putExtra("url", url)
            context.startActivity(intent)
        }
    }

    override fun initView() {
        var url = intent.getStringExtra("url")
        if (!TextUtils.isEmpty(url)) {
            Glide.with(this).load(url).into(ivContent)
        } else {
            ivContent.scaleType = ImageView.ScaleType.CENTER_INSIDE
            ivContent.setImageResource(R.mipmap.ic_launcher)
        }
    }
}
